package com.woniuxy.tms.accept.utils;

import com.ruoyi.common.core.web.domain.BaseEntity;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.woniuxy.tms.accept.domain.MyBaseEntity;
import org.apache.poi.ss.formula.functions.T;
import java.util.Date;
import java.util.List;

/**
 * @Version 1.0
 * @ClassName: BeanUtils
 * @Description: 工具类
 * @Author 邓贤文
 * @Date: 2022/4/20 19:22
 */
public class BeanUtils<T>{

    /**
     * 在新增操作时候,为参数添加参数
     * @param obj
     * @param <T>
     * @return
     */
    public static<T extends MyBaseEntity> T addAddParams(T obj){
        obj.setCreatedTime(new Date());
        obj.setCreatedBy(SecurityUtils.getUserId());
        obj.setUpdatedTime(new Date());
        obj.setUpdatedBy(SecurityUtils.getUserId());
        return obj;
    }

    /**
     *  在更新操作时候,为参数添加参数
     * @param obj
     * @param <T>
     * @return
     */
    public static<T extends MyBaseEntity> T updateAddParams(T obj){
        obj.setUpdatedTime(new Date());
        obj.setUpdatedBy(SecurityUtils.getUserId());
        return obj;
    }
}
